package com.darren.euc.dao.impl;


import java.util.List;

import org.hibernate.Query;
import org.hibernate.Session;
import org.springframework.stereotype.Repository;

import com.darren.euc.dao.ContractHirePurchaseDao;
import com.darren.euc.entity.ContractHirePurchase;


@Repository
public class ContractHirePurchaseDaoImpl extends BaseDaoImpl<ContractHirePurchase, Integer> implements ContractHirePurchaseDao {
	
	@Override
	public List<ContractHirePurchase> getAll() {
		Session session = sessionFactory.getCurrentSession();	
		@SuppressWarnings("unchecked")
		List<ContractHirePurchase> contractHirePurchases = session.createQuery("from ContractHirePurchase where enable = true").list();
		return contractHirePurchases;
	}

	@Override
	public void deleteByContractId(Integer contractId) {
		Session session = sessionFactory.getCurrentSession();
		Query query = session.createSQLQuery("delete from euc_contract_hire_purchase where contract_id = ?");
		query.setParameter(0, contractId);
		query.executeUpdate();
	}


}